<%--
  Created by IntelliJ IDEA.
  User: zc
  Date: 2024/7/17
  Time: 17:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录后页面</title>
</head>
<body>
<%
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String flag = request.getParameter("flag");
    if (flag == null) {
        if (username.equals("zc") && password.equals("123")) {
%>
<%=username%>登陆成功
<%
} else {
%>
<%=username%>1登陆失败
<%
    }
} else {
    //取得所有cookie
    Cookie[] cookies = request.getCookies();
    Cookie cookie = cookies[0];
    String name = cookie.getName();
    String value = cookie.getValue();
    if (name.equals(username) && value.equals(password)) {
%>
登陆成功
<%
} else {

request.getRequestDispatcher("error.jsp").forward(request,response);
        }

    }
%>
<%--${username}--%>

<%--    //    response.setHeader("refresh","3; withdraw.jsp");--%>
<%--//重定向 客户端跳转--%>
<%--//response.sendRedirect("withdraw.jsp");--%>
<%--//内部跳转，后面代码不执行--%>
<%--//request.getRequestDispatcher("withdraw.jsp").forward(request,response);--%>

<% session
    .
    setAttribute
    (
    "username"
    ,
    username
    )
    ;%>
<a href="withdraw.jsp">点这个立刻跳转</a>
</body>
</html>
